package com.gdevelop.examples.demo.client;


import com.gdevelop.gwtxp.client.GwtXP;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SimplePanel;

public class MainWindowController extends BaseController{
  public MainWindowController() {
  }
  
  public void unimplemented(){
    Window.alert(getConstants().unimplementedCommand());
  }
  
  public void showArrayConstants(){
    showPanel("ArrayConstants");
  }
  public void showBasicBinding(){
    showPanel("BasicBinding");
  }
  public void showBindingWithConverter(){
    showPanel("BindingWithConverter");
  }
  public void showBindingValidator(){
    showPanel("BindingValidator");
  }
  
  public void showListBinding(){
    showPanel("ListBinding");
  }
  public void showTableBinding(){
    showPanel("TableBinding");
  }
  public void showEditableTable(){
    showPanel("EditableTable");
  }
  public void showMasterDetail(){
    showPanel("MasterDetail");
  }
  public void showUsers(){
    showPanel("Users");
  }
  
  private void showPanel(String name){
    Demo.mainWindowSource.removeFromParent();
    
    // remove existing child
    SimplePanel contentPanel = (SimplePanel)((GwtXP)this).getUI("contentPanel");
    if (contentPanel.getWidget() != null){
      contentPanel.getWidget().removeFromParent();
    }
    
    ContentWidget w = new ContentWidget(name);
    contentPanel.add(w);
  }
}
